package org.wzry.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

public class Wzryinfo {
	/**
	 * 读取路径获取全部文本
	 * @param way 路径
	 * @return
	 * @throws IOException
	 */

	public static String info(String way) {
		//需要在目录下面存在'文件'否则会奔溃
		//服务器：C:\Users\Administrator\Desktop\web\tomcat\webapps\wzry\wzry\王者荣耀-武器.txt
		//本地机：System.getProperty("user.dir")+"\\src\\main\\webapp\\wzry\\王者荣耀-武器.txt
		File file = new File(way);
		 InputStreamReader f = null;
		try {
			f = new  InputStreamReader(  new FileInputStream(file),"GBK");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 BufferedReader b = new BufferedReader(f);
		 String text = null;
		 String texts = "";
		 //读取文本里面全部内容
		 try {
			while((text = b.readLine()) != null){
				 	texts += text;
			 }
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		return texts;
	}
}
